package org.xs.web.http;

import java.util.List;

public class BeforExeception extends RuntimeException{

	private static final long serialVersionUID = 1L;
	private String msg;
	private List<Exception> exceptions;
	
	public BeforExeception(String msg){
		super(msg);
		this.msg = msg;
	}
	
	public String getMessage(){
		return msg;
	}

	public BeforExeception(){
		super();
	}
	
	public BeforExeception(Throwable throwable){
		super(throwable);
	}
	
	public BeforExeception(String msg,List<Exception> es){
		super(msg);
		this.msg = msg;
		exceptions = es;
	}
	@Override
	public String toString(){
		StringBuilder sb = new StringBuilder();
		sb.append("<div class='error'>");
		sb.append("<p>Message: ").append(msg).append("</p>");
		sb.append("<div>Cause: ");		
		for(Exception e: exceptions){
			sb.append(e.getCause() == null ? e.getMessage() : e.getCause().toString());
			sb.append("</br>");
		}
		sb.append("</div>");
		sb.append("</div>");
		return sb.toString();
		
	}
	
}
